package mybatis.main;

import static java.lang.System.out;

import java.io.Reader;

import mybatis.domain.User04;
import mybatis.mapper.Mapper04;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

//mapper04.xml, SqlMapConfig.xml
public class Main04 {	
	public static void main(String[] args) throws Exception{		
		Reader reader = Resources.getResourceAsReader("config/SqlMapConfig.xml");		
		SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);		
		SqlSession sqlSession = sqlSessionFactory.openSession();
		
		Mapper04 mapper = sqlSession.getMapper(Mapper04.class);
				
		out.println("[getUsers]");
		for(User04 user: mapper.getUsers()) 
			out.println(user);
		
		out.println("[getUsers02]");
		for(User04 user: mapper.getUsers02()) 
			out.println(user);
	}
}